﻿Public Class StreamPlayer
    Private _strSessionID As String
    Private _strApiKey As String
    Sub New(ByVal apikey As String, ByVal sessionID As String, ByVal mediumID As String)

        ' This call is required by the Windows Form Designer.
        InitializeComponent()


        ' Add any initialization after the InitializeComponent() call.

        _strApiKey = apikey
        _strSessionID = sessionID

        If mediumID <> "" Then
            Dim oStreaming As New Streaming(apikey, sessionID)
            Dim strUrl As String
            strUrl = oStreaming.GetStreamingUri(Streaming.TYPE_ASX, mediumID, 320, 240)
            oWmp.URL = strUrl
            oWmp.Ctlcontrols.play()
        Else
            'let the programmer handle it by himself.
        End If
    End Sub

    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

    End Sub

    Public Property SessionID() As String
        Get
            Return _strSessionID
        End Get
        Set(ByVal value As String)
            _strSessionID = value
        End Set
    End Property

    Public Property ApiKey() As String
        Get
            Return _strApiKey
        End Get
        Set(ByVal value As String)
            _strApiKey = value
        End Set
    End Property

    Sub PlayStream(ByVal mediumID As String)
        If _strApiKey = "" Then
            Throw New OrbNoApiKeyException
            Exit Sub
        End If
        If _strSessionID = "" Then
            Throw New OrbNoSessionIdFailure
            Exit Sub
        End If

        Dim oStreaming As New Streaming(_strApiKey, _strSessionID)
        Dim strUrl As String
        strUrl = oStreaming.GetStreamingUri(Streaming.TYPE_ASX, mediumID, 320, 240)
        oWmp.URL = strUrl
        oWmp.Ctlcontrols.play()
    End Sub


    
End Class
